<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="admin/_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.10/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/mycss.css">
    <title>博客管理</title>
</head>
<body>
<!--导航-->
<nav th:replace="admin/_fragments :: menu(1)" class="ui inverted attached segment my-padding-small my-shadow-small"><!--attached会连接上一个模块，没有缝隙-->
    <div class="iu container">
        <div class="ui inverted secondary stackable menu"> <!--menu导航条;   stackable会让导航栏以堆积的方式适应屏幕-->
            <h2 class="ui teal header item">管理后台</h2>  <!--item让这部分成为导航栏的条目-->
            <a href="" class="active my-item item my-mobile-hide"><i class="home icon"></i>博客</a>
            <a href="" class="my-item item my-mobile-hide"><i class="idea icon"></i>发布</a>
            <a href="" class="my-item item my-mobile-hide"><i class="tags icon"></i>列表</a>
            <div class="right my-mobile-hide menu">
                <div class="ui dropdown item"><!--dropdown效果是鼠标放在item时会让该部分更显眼；-->
                    <div class="text">
                        <img class="ui avatar image" src="../../static/image/山城.jpg">
                        承太郎
                    </div>
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="" class="item">注销</a>
                    </div>
                </div>
            </div>

        </div>
    </div>
    <div href="" class="ui my-menu toggle black icon button my-right-top my-mobile-show">
        <i class="sidebar icon"></i><!--三条横杠图标-->
    </div>
</nav>
<div class="ui attached pointing menu">
    <div class="ui container">
        <div class="right menu">
            <a href="" class="item">发布</a>
            <a href="" class="active teal item">列表</a>
        </div>

    </div>
</div>

<!--中间-->
<div class="my-container-small my-padding-large">
    <div class="ui container">
        <div  class="ui segment secondary form">
            <input type="hidden" name="page" >
            <div class="inline fields">
                <div class="field">
                    <input type="text" name="title" class="text" placeholder="标题">
                </div>
                <div class="field">
                    <div class="ui labeled action input">
                        <div class="field">
                            <div class="ui type selection dropdown">
                                <input type="hidden" name="type.id">
                                <i class="dropdown icon"></i>
                                <div class="default text">分类</div>
                                <div class="menu">
                                    <div th:each="type : ${types}" class="item" data-value="1" th:data-value="${type.id}" th:text="${type.name}">Error</div>
                                    <!--/*-->
                                    <div class="item" data-value="2">Log</div>
                                    <!--*/-->
                       </div>
                    </div>
                  </div>
                      <button id="clear-btn" class="ui compact button">清空</button>
                  </div>
                </div>


                <div class="field" >
                    <div class="ui checkbox">
                        <input type="checkbox" id="recommend" name="recommend">
                        <label for="recommend">推荐</label>
                    </div>
                </div>
                <div class="field">
                    <button type="button" id="search-btn" class="ui mini teal basic button">
                        <i class="search icon"></i>搜索
                    </button>
                </div>
            </div>
        </div>
        <div id="table-container">
            <table th:fragment="blogList" class="ui celled compact teal table ">
                <thead>
                <tr>
                    <th></th>
                    <th>标题</th>
                    <th>类型</th>
                    <th>推荐</th>
                    <th>更新时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr align="center" th:each="blog,iterStat : ${page.content}">
                    <td th:text="${iterStat.count}">1</td>
                    <td th:text="${blog.title}">刻意练习清单</td>
                    <td th:text="${blog.type.name}">认知升级</td>
                    <td th:text="${blog.recommend} ? '是':'否'">是</td>
                    <td th:text="${blog.published} ? '发布':'草稿'">草稿</td>
                    <td th:text="${blog.updateTime}">2017-10-02 09:45</td>
                    <td>
                        <a href="#" th:href="@{/admin/blogs/{id}/input(id=${blog.id})}" class="ui mini teal basic button">编辑</a>
                        <a href="#" onclick="return confirm('确定要删除该文章吗？三思啊! 删了可就没了！')"  th:href="@{/admin/blogs/{id}/delete(id=${blog.id})}" class="ui mini red basic button">删除</a>
                    </td>
                </tr>
                </tbody>
                <tfoot>
                <tr>
                    <th colspan="7">
                        <div class="ui mini pagination menu" th:if="${page.totalPages}>1" >
                            <a onclick="page(this)" th:attr="data-page=${page.number}-1" class="item" th:unless="${page.first}">上一页</a>
                            <a onclick="page(this)" th:attr="data-page=${page.number}+1" class="item" th:unless="${page.last}">下一页</a>
                        </div>
                        <a  href="#" th:href="@{/admin/blogs/input}" class="ui mini right floated teal basic button">新增</a>
                    </th>
                </tr>
                </tfoot>
            </table>
        </div>

        <div class="ui success message" th:unless="${#strings.isEmpty(message)}">
            <i class="close icon"></i>
            <div class="header">提示：</div>
            <p th:text="${message}">恭喜，操作成功！</p>
        </div>
</div>
</div>

<!--底部-->
<footer th:replace="admin/_fragments :: footer" class="ui inverted vertical segment my-padding-massive">
    <div class="ui container diy_dp">
        <div class="ui stackable center aligned inverted divided grid">
            <div class="three wide column">
                <img src="../../static/image/微信.jpg" class="ui rounded image centered aligned" alt="" style="width: 130px">
            </div>

            <div class="three wide column">
                <h4 class="ui inverted header">最新博客</h4>
                <div class="ui inverted link list"></div>
                <a href="" class="item">碧蓝航线攻略</a><br>
                <a href="" class="item">游戏抽奖技巧</a><br>
                <a href="" class="item">如何与傻逼交流</a>
            </div>

            <div class="three wide column">
                <h4 class="ui inverted header">最新博客</h4>
                <div class="ui inverted link list"></div>
                <a href="" class="item">碧蓝航线攻略</a><br>
                <a href="" class="item">游戏抽奖技巧</a><br>
                <a href="" class="item">如何与傻逼交流</a>
            </div>

            <div class="seven wide column">
                <h4 class="ui inverted header">最新博客</h4>
                <p class="my-text-spaced my-text-thin my-opacity-mini">这是我的个人博客，赶紧进去看看，你们不要不知好歹</p>
            </div>

        </div>
        <div class="ui inverted section divider"></div>
        <p class="my-text-spaced my-text-thin my-opacity-tiny">Copyright @ 2021-2022 MrWuu Designed by MrWuu</p>
    </div>

</footer>


<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.10/semantic.min.js"></script>

<script>
    $('.my-menu.toggle').click(function () {
        $('.my-item').toggleClass('my-mobile-hide');
        /*toggleClass效果：点击之后如果有my-mobile-hide这一个样式就去除掉
        如果没有则加上去*/
        /*这个js原理是先获取.my-menu toggle的作用域再把后面点击之后的效果加上来
            点击效果是由获取.my-item的作用域,加上toggleClass给的功能组成的*/
    });

    $('.ui.dropdown').dropdown({
        on: 'hover'
    })
    ;

    //消息提示关闭初始化
    $('.message .close')
        .on('click', function () {
            $(this)
                .closest('.message')
                .transition('fade');
        });

    $('#clear-btn')
        .on('click', function() {
            $('.ui.type.dropdown')
                .dropdown('clear');
        });

    function page(obj) {
        $("[name='page']").val($(obj).data("page"));
        loaddata();
    }

    $("#search-btn").click(function () {
        $("[name='page']").val(0);
        loaddata();
    });
    function loaddata() {
        $("#table-container").load(/*[[@{/admin/blogs/search}]]*/"/admin/blogs/search",{
            title : $("[name='title']").val(),
            typeId : $("[name='typeId']").val(),
            recommend : $("[name='recommend']").prop('checked'),
            page : $("[name='page']").val()
        });
    }

</script>

</body>
</html>